package _作业;

import java.util.Scanner;

public class Version_alliance {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String[] caidan = new String[]{"红烧带鱼", "鱼香肉丝", "大大白菜"};//菜单
        double[] danjia = new double[]{38.0, 20.0, 10.0};//单价
        int length=5;
        String[] candai = new String[length];//餐袋
        int[] fenshu = new int[length];//份数
        int[] qianshou = new int[length]; //签收状态
        int[] dianzan = new int[3]; //点赞

        System.out.println("只要动动手指，就能送餐上门”，网上定餐深受现代人青睐，现开发一个网上订餐系统，功能如下");
        while (true) {
            System.out.println("1.我要订餐");
            System.out.println("2.查看餐袋");
            System.out.println("3.签收订单");
            System.out.println("4.删除订单");
            System.out.println("5.我要点赞");
            System.out.println("6.退出系统");
            System.out.print("选择功能:");
            int a = input.nextInt();  //选择功能
            switch (a) {
                case 1://订餐
                    System.out.println("菜单如下：\n菜品序列\t菜品名称\t单价\t顾客点赞");
                    for (int b = 0; b < caidan.length; b++) {
                        System.out.println((b + 1) + "\t" + caidan[b] + "\t" + danjia[b] + "\t" + dianzan[b]);
                    }
                    System.out.print("选择您喜欢的菜品：");
                    int x = input.nextInt();
                    while (x < 1 || x > 3) {
                        System.out.print("没有此菜品，请重新选择");
                        x = input.nextInt();
                    }
                    System.out.println("收餐人姓名：");
                    String xxxxx = input.next();

                    System.out.print("需要几份:");
                    int xx = input.nextInt();
                    System.out.print("请输入送餐时间：");
                    double xxx = input.nextInt();
                    while (xxx < 8 || xxx > 24) {
                        System.out.println("这个时间不送，请重新选择");
                        xxx = input.nextInt();
                    }
                    System.out.println("送餐地址:");
                    String xxxx = input.next();
                    double money = (danjia[x - 1] * xx >= 50) ? danjia[x - 1] * xx : danjia[x - 1] * xx + 5;  //计算餐费
                    String u = "\t" + xxxxx + "\t" + caidan[x - 1] + "\t\t" + xx + "份\t\t" + xxx + "\t\t" + xxxx + "\t\t" + money; //餐袋
                    int b = 0;
                    for (; b < candai.length; b++) {
                        if (candai[b] == null) {
                            candai[b] = u;
                            fenshu[b] = xx;
                            break;
                        } else if (b == candai.length - 1 && candai[b] != null) {
                            System.out.println("餐袋已满，删除订单");
                        }
                    }
                    System.out.println("您的餐袋编号为：" + (b + 1) + "\n" + u);
                    break;
                case 2://查看餐袋
                    System.out.println("请输入您的餐袋编号：");
                    int o = input.nextInt();
                    String zhuangtai=qianshou[o-1]>0?"已签收":"未签收";
                    if (candai[o - 1] != null) {
                        System.out.println("收餐人姓名\t菜\t\t份数\t\t送餐时间\t\t送餐地址\t\t总价钱 签收状态");
                        System.out.println(candai[o - 1] + "\t" + zhuangtai);
                    } else {
                        System.out.println("没有这个订单");
                    }
                    break;
                case 3://签收订单
                    System.out.println("请输入您的订单编号：");
                    int c = input.nextInt();
                    if (qianshou[c - 1] == 1) {
                        System.out.println("订单已签收，无需再次签收");
                    } else if (candai[c - 1] != null && qianshou[c - 1] < 1) {
                        qianshou[c - 1]++;
                        System.out.println("已签收");
                    } else {
                        System.out.println("无此订单");
                    }
                    break;
                case 4://删除订单
                    System.out.println("请输入您要删除的订单编号：");
                    int p = input.nextInt();
                    if (qianshou[p - 1] != 0) {
                        for (int oo=p-1;oo< candai.length-1;oo++){
                            candai[oo]=candai[oo+1];
                        }
                        candai[length-1]=null;
                        fenshu[length-1]=0;
                        qianshou[length-1]=0;
                    } else if (qianshou[p - 1] == 0) {
                        System.out.println("订单未签收，无法删除");
                    } else {
                        System.out.println("没有此订单");
                    }
                    break;
                case 5://点赞
                    System.out.print("请输入要点赞的菜品：");
                    int y = input.nextInt();
                    while (y < 1 || y > 3) {
                        System.out.println("菜单编号错误");
                        y = input.nextInt();
                    }
                    dianzan[y - 1]++;
                    System.out.println("点赞成功");
                    break;
                case 6:
                    System.out.println("欢迎您的下次使用");
                    return;
                default:
                    System.out.println("无此功能重新选择");
            }
        }
    }
}